/**
 * 
 */

window.onload = initPage;
var ped;
var test = "none";
var aux = 0;

function createRequest() {
    try {
        request = new XMLHttpRequest();
    } catch (tryMS) {
        try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (otherMS) {
            try {
                request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (failed) {
                request = null;
            }
        }
    }
    return request;
}

function efetuarLogin(){
	user = document.getElementById("usr").value;
        senha = document.getElementById("pass").value;
        
        alert("tentando logar com user: " + user + " e senha: " + senha);
	
	request = createRequest();
	
	if (request == null) {
        alert("Unable to create request");
        return;
    }
	

    var url= "/ProjetoRR/Testes/LoginServlet?acao=logar&user="+escape(user)+"&senha="+escape(senha);
    
    request.open("POST", url, true);
    request.onreadystatechange = displayLogin;
    request.send(null);
	
}


function displayLogin() {
    if (request.readyState == 4) {
        if (request.status == 200) {
            detailDiv = document.getElementById("user");
            detailDiv.innerHTML = request.responseText;
        }
    }
}
